package GameItem.Direction
{
	import Cotrol.GameTickControl;
	
	import GameItem.IGameItem;
	
	import flash.events.Event;
	import flash.geom.Point;
	import flash.display.DisplayObject;

	public class Direction
	{
		
		public function Direction()
		{
			
		}
		public function moveGameItem(gameItem:IGameItem,speed:int):void
		{
			//var targetPos:Point=getMoveTargetPos(gameItem.position);
			var tickNum:int=calculateTickNum(speed);
			
			var move:Function=function (evt:Event):void
			{
				if(tickNum<=0)
				{
					GameTickControl.getInstance().removeEventListener(GameTickControl.GAMETICK,move);
					moveItemToTarget(gameItem);
				}
				else
				{
					tickNum--;
				}
			};
			
			GameTickControl.getInstance().addEventListener(GameTickControl.GAMETICK,move);
		}
		private function calculateTickNum(speed:int):int
		{
			return 3;
		}


		protected function moveItemToTarget(gameItem:IGameItem):void
		{
			throw new Error("Direction子类为改写getMoveTargetPos");
		}
	}
}